local zhongyun = fk.CreateSkill{
    name = "jinhs__zhongyun",
}

Fk:loadTranslationTable{
    ["jinhs__zhongyun"] = "忠允",
    [":jinhs__zhongyun"] = "每回合限一次，当你获得或失去手牌后，若你的体力值与你的手牌数相等，你摸一张牌或弃置一名其他角色的一张牌。",

    ["#jinhs__zhongyun-discard"] = "忠允：弃置一名其他角色的一张牌，或点“取消”摸一张牌",

    ["$jinhs__zhongyun1"] = "秉公行事，无所亲疏。",
    ["$jinhs__zhongyun2"] = "明晰法理，通晓人情。",
}

zhongyun:addEffect(fk.AfterCardsMove,{
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
    if player:hasSkill(zhongyun.name) and player.hp == player:getHandcardNum() and player:usedSkillTimes(zhongyun.name, Player.HistoryTurn) == 0 then
      for _, move in ipairs(data) do
        if move.to == player and move.toArea == Card.PlayerHand then
          return true
        end
        for _, info in ipairs(move.moveInfo) do
          if move.from == player and info.fromArea == Card.PlayerHand then
            return true
            end
          end
        end
      end
    end,
    on_use = function(self, event, target, player, data)
       local room = player.room
       local targets = table.filter(room:getOtherPlayers(player), function (p) return not p:isNude() end)
       if #targets > 0 then
         local to = room:askToChoosePlayers(player,{
            targets = targets,
            min_num = 1,
            max_num = 1,
            prompt = "#jinhs__zhongyun-discard",
            skill_name = zhongyun.name,
            cancelable = true,
         })
         if #to > 0 then
         local id = room:askToChooseCard(player,{
            target = to[1],
            flag = "he",
            skill_name = zhongyun.name,
        })
        room:throwCard(id, zhongyun.name, to[1], player)
        else
        player:drawCards(1, zhongyun.name)
        end
      else
        player:drawCards(1, zhongyun.name)
      end
    end,
})

return zhongyun